home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / 93win / data1.cab / DLL_Toolkit / Source / HTBTree / htbtree.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2005-03-02  |  2.6 KB  |  115 lines

  1. /***********************************************
  2.  htbtree.dll
  3.   
  4.  htbtree.cpp
  5.  
  6.  Copyright TransEra Corporation 1999.
  7. ************************************************/
  8.  
  9. #include "stdafx.h"
  10. #include "htbtree.h"
  11.  
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18. BEGIN_MESSAGE_MAP(CHtbtreeApp, CWinApp)
  19.     //{{AFX_MSG_MAP(CHtbtreeApp)
  20.         // NOTE - the ClassWizard will add and remove mapping macros here.
  21.         //    DO NOT EDIT what you see in these blocks of generated code!
  22.     //}}AFX_MSG_MAP
  23. END_MESSAGE_MAP()
  24.  
  25. CHtbtreeApp::CHtbtreeApp()
  26. {
  27. }
  28.  
  29. /////////////////////////////////////////////////////////////////////////////
  30. /*
  31.     Function:        BrowseCallbackProc
  32.  
  33.     Description:    Call pack Function
  34.  
  35.     Return type:    
  36.     Argument:        HWND hwnd
  37.     Argument:        UINT uMsg
  38.     Argument:        LPARAM lp
  39.     Argument:        LPARAM pData
  40.  
  41.     Notes:            Serves as message pump
  42.         
  43. */
  44.  
  45. int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData) 
  46. {
  47.    TCHAR szDir[MAX_PATH];
  48.  
  49.    switch(uMsg) 
  50.    {
  51.       case BFFM_INITIALIZED: 
  52.           {
  53.                 if ( GetCurrentDirectory(sizeof(szDir)/sizeof(TCHAR), szDir)) 
  54.                 {
  55.             // WParam is TRUE since you are passing a path.
  56.             // It would be FALSE if you were passing a pidl.
  57.             SendMessage(hwnd,BFFM_SETSELECTION,TRUE,(LPARAM)szDir);
  58.          }
  59.          break;
  60.       }
  61.       case BFFM_SELCHANGED: 
  62.           {
  63.          // Set the status window to the currently selected path.
  64.          if (SHGetPathFromIDList((LPITEMIDLIST) lp ,szDir)) {
  65.             SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)szDir);
  66.          }
  67.          break;
  68.       }
  69.       default:
  70.          break;
  71.    }
  72.    return 0;
  73. }
  74.  
  75. /////////////////////////////////////////////////////////////////////////////
  76. /*
  77.     Function:        Tctrl
  78.  
  79.     Description:    Calls Tree Control
  80.  
  81.     Return type:    void 
  82.     Argument:        char * StaticTitle
  83.     Argument:        char * ReturnPath
  84.  
  85.     Notes:            Calls tree control and returns pathname to HTBasic.
  86.         
  87. */
  88.  
  89. void Tctrl(char * StaticTitle, char * ReturnPath)
  90. {
  91.     BROWSEINFO bi;
  92.     LPITEMIDLIST pidl;
  93.     LPMALLOC pMalloc;
  94.  
  95.     if (SUCCEEDED(SHGetMalloc(&pMalloc))) 
  96.     {
  97.       ZeroMemory(&bi,sizeof(bi));
  98.       bi.hwndOwner = NULL;
  99.       bi.pszDisplayName = 0;
  100.             bi.lpszTitle = StaticTitle;
  101.       bi.pidlRoot = 0;
  102.       bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
  103.             bi.ulFlags &= ~BIF_DONTGOBELOWDOMAIN;
  104.             bi.ulFlags &= ~BIF_BROWSEFORCOMPUTER;
  105.             bi.ulFlags &= ~BIF_BROWSEFORPRINTER;
  106.       bi.lpfn = BrowseCallbackProc;
  107.  
  108.       pidl = SHBrowseForFolder(&bi);
  109.       if (pidl) {
  110.         SHGetPathFromIDList(pidl,ReturnPath);        
  111.         pMalloc->Free(pidl);
  112.         pMalloc->Release();
  113.       }
  114.     }
  115. }